<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>传智健康</title>
    <meta name="description" content="传智健康">
    <meta name="keywords" content="传智健康">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../css/style.css">
    <script src="../plugins/echarts/echarts.js"></script>
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
</head>
<body class="hold-transition">
<div id="app">
    <template>
    <div class ="block" style="margin: 10px 400px">
        <span class="demonstration"></span>
        <el-date-picker
                v-model="value2"
                type="month"
                placeholder="选择日期"
                format="yyyy 年 MM 月"
                value-format="yyyy-MM"
                @change="test()">
        </el-date-picker>
    </div>
    </template>
</div>

    <div class="content-header">
        <h1>统计分析
            <small>每个套餐数量</small>
        </h1>
        <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>统计分析</el-breadcrumb-item>
            <el-breadcrumb-item>每个套餐数量</el-breadcrumb-item>
        </el-breadcrumb>
    </div>

    <div class="app-container">

        <div class="box">
            <!-- 为 ECharts 准备一个具备大小（宽高）的 DOM -->
            <div id="chart" style="height: 600px"></div>
        </div>
    </div>
</div>
</body>
<!-- import Vue before Element -->
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<!-- import JavaScript -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script src="../js/axios-0.18.0.js"></script>
<script>

    new Vue({
        el:"#app",
        data:{
            value2:""
        },
        created() {
            var dateStr = new Date().getFullYear()+"-"+new Date().getMonth()+1;
            this.value2 = dateStr;
            this.test()
        },
        methods:{
            test(){
                console.log(this.value2)
                if (this.value2 !=null){
                    axios.get("http://api.oms.health.itcast.com:9002/report/getMonthByCount.do?dateValue="+this.value2).then((res) => {
                        // 使用刚指定的配置项和数据显示图表。
                        myChart.setOption({
                            title: {
                                text: '套餐预约人数',
                                subtext: '饼状图',
                                left: 'center'
                            },
                            tooltip: {
                                trigger: 'item',
                                formatter: '{a} <br/>{b} : {c} ({d}%)'
                            },
                            legend: {
                                orient: 'vertical',
                                left: 'left',
                                data: res.data.data.setmealNames
                            },
                            series: [
                                {
                                    name: '访问来源',
                                    type: 'pie',
                                    radius: '55%',
                                    center: ['50%', '60%'],
                                    data: res.data.data.setmealCount,
                                    emphasis: {
                                        itemStyle: {
                                            shadowBlur: 10,
                                            shadowOffsetX: 0,
                                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                                        }
                                    }
                                }
                            ]
                        });
                    });
                }
            }
        }
    })

    // 基于准备好的dom，初始化echarts实例
   var myChart = echarts.init(document.getElementById('chart'));

    //myChart.setOption(member);

</script>
</html>